package service;

import java.util.List;

import javax.persistence.EntityManager;

public abstract class GenericDAOImpl<T> implements GenericDAO<T> {

	protected EntityManager entityManager;
	
	@Override
	public void removeObjeto(Long objId) {
		T obj = localizaObjeto(objId);
		if (obj != null) {
			entityManager.remove(obj);
		}
	}
	
	@Override
	public void insereObjeto(T obj) {
		entityManager.persist(obj);
	}
	
	public abstract T localizaObjeto(Long objId);
	
	public abstract List<T> listaObjetos();
	
	public abstract void deletaObjetos();

}
